package com.cloud.photo.album.persist.dao.impl;

import java.util.HashMap;
import java.util.Map;

import com.cloud.photo.album.model.dbobject.UserLogin;
import com.cloud.photo.album.persist.dao.UserLoginDao;

public class UserLoginDaoImpl extends DaoBase<UserLogin> implements UserLoginDao{

	public UserLoginDaoImpl() {
		super.setClazz(UserLogin.class);
		super.setPrefix("userLogin");
	}
	
	@Override
	public boolean userLogin(UserLogin userLogin) {
		boolean flag = false;
		UserLogin[] resultObjectList =  (UserLogin[])super.selectObjectList(userLogin);
		if(resultObjectList != null && resultObjectList.length != 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean insertUserLogin(UserLogin userLogin) {
		boolean flag = false;
		int result =super.add(userLogin);
		if(result == 1) {
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean mailExist(String userEmail) {
		boolean flag = false;
		Map<String, String> params = new HashMap<String, String>();
		params.put("userEmail", userEmail);
		UserLogin[] userLoginArray = (UserLogin[])super.select(params);
		if(userLoginArray != null && userLoginArray.length != 0) {
			flag = true;
		}
		return flag;
	}

}
